import json
# 将字典转换为json字符串,key用双引号""
dict1 = {"name": "zhangsan", "age": 18, "sex": "男"}
print(json.dumps(dict1))

